#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_highfunc.py
# author:Jackiex
# datetime:2023/5/4 14:04
# software: PyCharm

"""
this is function  description 
"""


# print(abs(-10))

# f = abs
#
# print(f(-10))

# 1--函数中的参数也是一个函数
# def add(x, y, f):
#     return f(x) + f(y)
#
#
# sum = add(-2, 5, abs)
#
# print(sum)
#


# 2 --函数的返回值，是另外一个函数
# def sonfunc():
#     print("in the sonfunc..")
#
# def highfunc(func):
#     print("这是我想额外做的事情..")
#     return func
#
# res = highfunc(sonfunc)
# res()

# import time
#
#
# def foo():
#     time.sleep(2)
#     print("from the foo")
#
#
# def soft_test(func):
#     return func
#
#
# foo = soft_test(foo)
# start = time.time()
# foo()
# end = time.time()
# print("执行时间%s" % (end - start))


# 高阶函数的用途

def lazy_sum(*args):
    def sum():
        ax = 0
        for n in args:
            ax = ax + n
        return ax

    return sum


f = lazy_sum(1, 2, 3, 4, 5, 6, 7, 8, 9)

print(f)

print(f())